package skiree.host.abetsy.controller;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import cn.dev33.satoken.exception.NotLoginException;

import java.util.HashMap;
import java.util.Map;

@CrossOrigin
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = NotLoginException.class)
    public Object handleNotLoginException(NotLoginException e) {
        Map<String, Object> result = new HashMap<>();
        Map<String, Object> meta = new HashMap<>();
        meta.put("msg", "认证失效, 请重新登录");
        meta.put("status", 401);
        result.put("meta", meta);
        return result;
    }

}